package demo6;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;

//模拟产生一个双色球的中奖号码
//红球 1-33: 6 不重复的,最终结果从小到大的
//蓝球 1-16: 1 nextInt(16)+1
//思路三:随机排序后取前6个

public class Demo03 {
    private static final ThreadLocalRandom r=ThreadLocalRandom.current();
    public static void main(String[] args) {
        for(int x=0;x<100;x++) {
            int blue = 0;
            Integer[] red = new Integer[6];
            blue = r.nextInt(16)+1;
            Integer[][] ball = new Integer[33][];
            for(int i=0;i<33;i++) {
                ball[i] = new Integer[] {i+1,r.nextInt()};

            }
            Arrays.sort(ball,(a,b)->a[1]-b[1]);
            for(int i=0;i<6;i++) {
                red[i] = ball[i][0];
            }
            Arrays.sort(red);
            System.out.println("篮球:"+blue);
            System.out.println("红球:"+Arrays.toString(red));
        }
    }

}
